import { createRouter, createWebHistory } from "vue-router";

const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: "/",
      redirect: "/login",
    },
    {
      path: "/login",
      component: () => import("../views/login/Login.vue"),
    },
    {
      path: "/layout",
      component: () => import("../views/layout/Layout.vue"),
      children: [
        {
          path: "",
          component: () => import("../views/home/Home.vue"),
        },
        {
          path: "category/:id",
          component: () => import("../views/Category/Category.vue"),
        },
        {
          path: "category/sub/:id",
          component: () => import("../views/subcategory/SubCategory.vue"),
        },
        {
          path: "detail/:id",
          component: () => import("../views/detail/Detail.vue"),
        },
      ],
    },
  ],
  // 路由行为配置
  scrollBehavior() {
    return {
      top: 0,
    };
  },
});

export default router;
